package com.hualan.servlet;

import com.alibaba.fastjson.JSON;
import com.hualan.service.ShopServiceDao;
import com.hualan.service.impl.ShopServiceDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

@WebServlet("/shop/addShop")
public class ShopAddServlet extends HttpServlet {
    ShopServiceDao shopServiceDao = new ShopServiceDaoImpl();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String shopAddress = req.getParameter("shopAddress");
        String shopDescribe = req.getParameter("shopDescribe");
        String shopImage = req.getParameter("shopImage");
        String shopLatitude = req.getParameter("shopLatitude");
        String shopLongitude = req.getParameter("shopLongitude");
        String shopName = req.getParameter("shopName");
        String shopPhone = req.getParameter("shopPhone");
        Map<String, Object> map = shopServiceDao.addShop(shopAddress, shopDescribe, shopImage, shopLatitude, shopLongitude, shopName, shopPhone);
        resp.getWriter().write(JSON.toJSONString(map));
    }
}
